import time
import multiprocessing

total =100000


def add_1(b,l):


    for i in range(10000):
        l.acquire()
        b.value = b.value + 2
        l.release()


def sub_1(b,l):


    for i in range(10000):
        l.acquire()
        b.value = b.value - 2
        l.release()



if __name__ == "__main__":
    balance = multiprocessing.Value('i',200)
    lock = multiprocessing.Lock()
    t1=multiprocessing.Process(target=add_1,args=(balance,lock))
    t2 = multiprocessing.Process(target=sub_1, args=(balance,lock))
    t1.start()
    t2.start()
    t1.join()
    t2.join()

    print (balance.value)